package ioStream.file.processStream.byteStream;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

/**
 * Created with IntelliJ IDEA
 * Description:对象字节输入流学习
 * User:22954
 * Date:2024-03-18
 * Time:17:36
 */
@SuppressWarnings("all")
public class ObjectInputStream_ {
    public static void main(String[] args) {
        String filePath = "f:/Test/data.txt";
        ObjectInputStream ois = null;
        try {
            ois = new ObjectInputStream(new FileInputStream(filePath));
            System.out.println(ois.readInt());
            System.out.println(ois.readChar());
            System.out.println(ois.readBoolean());
            System.out.println(ois.readFloat());
            System.out.println(ois.readUTF());
            Dog dog = (Dog) ois.readObject();
            System.out.println(dog);
            System.out.println(dog.getName());
        } catch (IOException e) {
            throw new RuntimeException(e);
        } catch (ClassNotFoundException e) {
            throw new RuntimeException(e);
        } finally {
            try {
                ois.close();
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
